package STX.entity;

public class Student extends Person {

    private Course choose;
    private Course withdrawal;

    public Student(int id, String name, String gender, Course choose, Course withdrawal) {
        super(id, name, gender);
        this.choose = choose;
        this.withdrawal = withdrawal;
        if (choose != null) {
            choose.addStudent(this); // 让课程知道有这个学生
        }
    }

    @Override
    public void printInfo() {
        super.printInfo();
        if (choose != null) {
            System.out.println("已选课程：" + choose.getClassName() +
                    "（地点：" + choose.getPlace() +
                    "，教师：" + choose.getTeacher().getName() + "）");
        }
        if (withdrawal != null) {
            System.out.println("退选课程：" + withdrawal.getClassName());
        }
    }
}
